<?php
declare (strict_types = 1);

namespace app\common\model;

class WholesaleProduct extends Base
{

    protected $name = 'wholesale_product';
    
    public function getToalTextAttr($value, $data)
    {
        $amcount = WholesaleOrder::where(['type'=>1,'product_id'=>$data['id']])->whereDay('create_time')->count();
        $pmcount = WholesaleOrder::where(['type'=>2,'product_id'=>$data['id']])->whereDay('create_time')->count();
        return '单场总单数：'.$data['toal'].'<hr>上午场剩余：'. ($data['toal']-$amcount).'<hr>下午场剩余：'.($data['toal']-$pmcount);
    }


}
